/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

import * as path from 'path';
import { parseJsonFile } from '../../../../src/common/util/parse-json/parse-json-util';
import { Json5Reader } from '../../../../src/base/util/json5-reader';

const json5FilePath = path.resolve('test/resource/application/common-test/build-profile.json5');

describe('test json5 reader', () => {

  test('test reader', () => {
    const jsonObj = Json5Reader.getJson5Obj(json5FilePath);
    expect(jsonObj.modules.length).toBe(1);
    expect(jsonObj.modules[0].name).toBe('module1');
  });

  test('test parse json5 with row&column',()=>{
    const jsonObj = parseJsonFile(json5FilePath, true);
    expect(jsonObj._line).toBe(1);
    expect(jsonObj._column).toBe(1);
    expect(jsonObj.modules[0]._line).toBe(3);
    expect(jsonObj.modules[0]._column).toBe(5);
  });
});
